/*
 * BaseGameEntity.java
 *
 * Created on March 27, 2007, 10:12 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package ai9hells.pgaibe.chapter2.westworldwithmessaging;

import ai9hells.pgaibe.common.messaging.Telegram;

/**
 *
 * @author andre.bandarra
 */
public abstract class BaseGameEntity {
    private static int nextValidId = 0;
    private int id;
    /** Creates a new instance of BaseGameEntity */
    public BaseGameEntity(int id) {
        setId(id);
    }
    
    public int getId(){
        return this.id;
    }
    public void setId(int id){
        if (id < nextValidId){
            throw new IllegalArgumentException("invalid ID");
        }
        this.id = id;
        nextValidId = id + 1;        
    }
    public abstract void update();
    public abstract boolean handleMessage(Telegram msg);
    
}
